#ifndef __BINARYTREE_H_
#define __BINARYTREE_H_
#include<iostream>
class BinaryTree
{
public:
    using ElementType=void*;
    BinaryTree();
    ~BinaryTree();
    void Insert(const ElementType&element);
  ElementType* FindElement(const ElementType&element);
    void Remove(const ElementType& element);
    void show();//前 中 后
    void setFunc(void (*print)(void*),bool (*compare)(void*,void*),bool (*cmpBig)(void*,void*))
    {
        this->print=print;
        this->compare=compare;
        this->cmpBig=cmpBig;
    }

private:
    struct   TreeNode
    {
        TreeNode(const ElementType&element):date(element)
        {
            Left=right=parent=nullptr;
        }
        ElementType date;//数据域
        TreeNode *Left;//左孩子
        TreeNode *right;//右孩子
        TreeNode *parent;//双亲节点
    };
    TreeNode * InsertNode(TreeNode*node,const ElementType&element);
    void PrevTravel(TreeNode*node);
    void MidTravel(TreeNode*node);
    void PostvTravel(TreeNode*node);
    void FreeNode(TreeNode* node);
    ElementType* FindNode(TreeNode*node,const ElementType& element);
    TreeNode *  RemoveNode(TreeNode*node,const ElementType& element);
    //获取一棵树中的最小值点
    TreeNode *GetMinNode(TreeNode*node);

    //右旋
    TreeNode *RotateRight(TreeNode *node);
    //左旋
    TreeNode *RotateLeft(TreeNode *node);
    //左右旋
    TreeNode *RotateLeftRight(TreeNode*node);
    //右左旋
    TreeNode *RotateRightLeft(TreeNode*node);
    
    int GetNodeHeight(TreeNode *node);
    //左右子树高度差
    int LRDeviation(TreeNode* node);
    bool (*compare)(void*,void*);//比较大小的指针
    bool (*cmpBig)(void*,void*);
    void (*print)(void*);//打印数据的指针
    TreeNode *root;
};


















#endif